<template>
  <j-modal
    :title="title"
    :width="1500"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <j-form-container :disabled="disableSubmit">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row>
            <a-table
              class="j-table-force-nowrap1"
              size="middle"
              bordered
              :dataSource="dataSource"
              :columns="columns"
              :rowKey="(record) => record.rowKey"
              :pagination="false"
            ></a-table>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-spin>
  </j-modal>
</template>

<script>

import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin'
import { getAction } from '@api/manage'

export default {
  name: 'SalesCollectionManagementOrderDetailModal',
  mixins: [JVxeTableModelMixin],
  components: {
  },
  data() {
    return {
      dataSource: [],
      validatorRules:{},
      title:'订单详细',
      width:800,
      visible: false,
      disableSubmit: true,
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '客户物料编码',
          dataIndex: 'customCode',
          align: 'center'
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '规格型号',
          dataIndex: 'noneSpec',
          align: 'center'
        },
        {
          title: '单位',
          dataIndex: 'unit_dictText',
          align: 'center'
        },
        {
          title: '数量',
          dataIndex: 'num',
          align: 'center'
        },
        {
          title: '单价',
          dataIndex: 'price',
          align: 'center'
        },
        {
          title: '金额',
          dataIndex: 'totalPrice',
          align: 'center'
        },
        {
          title: '实收数量',
          dataIndex: 'realNum',
          align: 'center'
        },
        {
          title: '收货金额',
          dataIndex: 'receivePrice',
          align: 'center'
        },
      ]
    }
  },
  methods:{
    crmDetail(rows){
      this.visible=true
      let orderIds = [];
      rows.forEach(item => {
        orderIds.push(...item.orderId.split(',')); // 正确拆分并合并数组
      });
      const uniqueOrderIds = [...new Set(orderIds)].join(',');
      console.log("11111111111111111",uniqueOrderIds)
      getAction('/procurement/salesCollectionManagement/selectOrderList',{orderId:uniqueOrderIds}).then(
        res=>{
          if(res.success){
            this.dataSource = res.result
          }
        }
      )
    },
    close () {
      this.$emit('close');
      this.visible = false;
    },
    handleOk () {
      this.submitForm();
    },
    submitCallback(){
      this.$emit('ok');
      this.visible = false;
    },
    handleCancel () {
      this.close()
    }
  }
}
</script>

<style scoped>
</style>
